import java.util.Scanner;

public class GuessNumber {
    public static void main(String[] args) {
            guessNumberGame();
        }
        public static void guessNumberGame () {
            while (true) {
                int choice = menu();
                if (choice == 1) {
                    game();
                } else if (choice == 0) {
                    System.out.println("白白~");
                    break;
                } else {
                    System.out.println("输入错误，请重试...");
                }
            }
        }
        public static void game () {
            System.out.println("欢迎来到猜数字小游戏，系统会随机生成1-100之间的数字，玩家将有七次机会来进行猜数字，如果猜到的数字与系统给定的数字相同，则通关，否则，游戏失败");
            int num = (int)(Math.random()*100+1);
            int times;
            Scanner sc = new Scanner(System.in);
            for (times = 6 ; times>=0;times--){
                int a = sc.nextInt();
                if(a>num){
                    System.out.println("大了，您还有"+times+"次机会");
                } else if (a<num) {
                    System.out.println("小了，您还有"+times+"次机会");
                }else if(a==num){
                    System.out.println("恭喜你猜对啦");
                    break;
                }
            }
            }

        public static int menu () {

            System.out.println("  1、开始游戏      0、退出  ");

            System.out.println("请输入您的选择：");
            Scanner scanner = new Scanner(System.in);
            int choice = scanner.nextInt();
            return choice;
        }

    }
